import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MaterialColorInfoVO, MaterialColorInfoForm, MaterialColorInfoQuery } from '@/api/material/materialColorInfo/types';

/**
 * 查询物料颜色列表
 * @param query
 * @returns {*}
 */

export const listMaterialColorInfo = (query?: MaterialColorInfoQuery): AxiosPromise<MaterialColorInfoVO[]> => {
  return request({
    url: '/material/materialColorInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询物料颜色详细
 * @param id
 */
export const getMaterialColorInfo = (id: string | number): AxiosPromise<MaterialColorInfoVO> => {
  return request({
    url: '/material/materialColorInfo/' + id,
    method: 'get'
  });
};

/**
 * 新增物料颜色
 * @param data
 */
export const addMaterialColorInfo = (data: MaterialColorInfoForm) => {
  return request({
    url: '/material/materialColorInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改物料颜色
 * @param data
 */
export const updateMaterialColorInfo = (data: MaterialColorInfoForm) => {
  return request({
    url: '/material/materialColorInfo',
    method: 'put',
    data: data
  });
};

/**
 * 删除物料颜色
 * @param id
 */
export const delMaterialColorInfo = (id: string | number | Array<string | number>) => {
  return request({
    url: '/material/materialColorInfo/' + id,
    method: 'delete'
  });
};
